/*
 * Copyright 2009 Brian Mackay brianwmackay@msn.com
 *   All Rights Reserved. See end of file
 *
 *   example usage  -model BlockSample.n3 
 */
package com.bmackay.vonsteuben.cmd;

import com.bmackay.vonsteuben.model.VonSteubenModelFactory;

public class CmdLine {

    public static final String Model = "-model";
    public static final String USE_ROOT_PATH = "-rootPath";
    public static final String HELP = "HELP";

    public static void main(String[] args) throws Exception {

        String path = makePath(args);
        if (path.equals(HELP)) {
            help();
        } else {
            VonSteubenModelFactory.createFullPath(path);
            //TODO: add Bette output model to process results
            System.out.println("Von Steuben Request Complete \n" );
        }
    }

    public static String makePath(String[] args) {
        String path = "";
        boolean useRootPath = true;

        if (args.length == 2 || args.length == 4) {

            for (int i = 0; i < args.length - 1; i = i + 2) {

                if (args[i].equalsIgnoreCase(Model)) {
                    path = args[i + 1];
                } else if (args[i].equalsIgnoreCase(USE_ROOT_PATH)) {
                    String b = args[i + 1];
                    useRootPath = Boolean.parseBoolean(b);
                } else {
                    return HELP;
                }
            }
        } else {
            System.out.println("INVALID ARGS:");
            help();
        }

        if (useRootPath == true) {
            path = ResourceBundleReader.getRoot() + path;
        }

        System.out.println("evaluating  model:" + path);
        return path;
    }

    private static void help() {
        System.out.println("help:");
        System.out.println();
        System.out.println("-model <path to Von Steuben Model>");
        System.out.println();
        System.out.println("example usage:  -model BlockSample.n3 -rootPath");

    }
}

/*
 * Copyright 2009 Brian Mackay brianwmackay@msn.com
 * All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */